<style>
    .basicinfo {
        margin: 15px 0;
    }

    .basicinfo .row > .col-xs-4 {
        padding-right: 0;
    }

    .basicinfo .row > div {
        margin: 5px 0;
    }
</style>
<div id="content-container" class="container">
    <div class="row">
        <div class="col-md-3">
            {include file="common/sidenav" /}
        </div>
        <div class="col-md-9">
            <div class="panel panel-default panel-page">
                <div class="panel-heading">
                    <h2>已使用保单（{$sum}份）</h2>
                </div>
                <div class="panel-body" style="padding:0;"> 


 
{volist name="list" id="vo" key="k"}
                                        <div class="row">
                       
                        <div class="col-md-11">
                            <h4>
                              {if $vo.insurance_company  eq 'PINGAN'}
                                <a href="/index/order/index.html?id={$vo.id}" target="_blank">中国平安汽车GPS盗抢责任险 {$vo.safe_years}年</a>
                              {else}
                                <a href="/index/order/index.html?id={$vo.id}" target="_blank">中国人民财产保险GPS

                                  <?php 
                                    if( $vo['big_number'] === "PZAH202042010000000051(NEW 10W)" || $vo['big_number'] =='PZAH202042010000000074(10W)'){
                                        echo '意外';
                                    }else{
                                        echo '盗抢';
                                    }
                                    ?>

                            责任险 {$vo.safe_years}年 </a>
                              {/if}
                            </h4> 
                            <p class="text-muted">编号：{$k+($query.page-1)*10}</p> 
                            <p class="text-muted">客户名字：{$vo.real_name}</p> 
                            <p class="text-muted">车牌号：{$vo.car_no}</p> 
                            <p class="text-muted">子保单号：{$vo.small_number}</p> 
                            <p class="text-muted">购买时间：{$vo.create_time|date="Y-m-d H:i:s",###}</p> 
                                                        <div class="btn-group">
                                <a class="btn btn-success btn-search" href="/index/order/index.html?id={$vo.id}" target="_blank" data-name="ueditor" data-version="1.0.3"><i class="fa fa-search fa-fw"></i> 查看详情</a> 

                                
                            </div>

<?php $differ= intval((time()-$vo['create_time'])/3600); 
if($differ<72){?>

                   <div class="btn-group">
                                <a class="btn btn-primary btn-more" href="javascript:nullify({$vo.id})"    data-name="ueditor" data-version="1.0.3"><i class="fa fa-paper-plane fa-fw"></i> 作废保单</a>  
                            </div>

<?php }?>




<?php $differ= intval((time()-$vo['create_time'])/3600); 
if($differ<168){?>

           <div  class="btn-group">
                                {if $vo.car_no eq ''}
    <a class="btn btn-info btn-ajax " href="javascript:editCarNo({$vo.id});" data-name="ueditor" data-version="1.0.3"><i class="fa fa-pencil fa-fw"></i> 编辑</a> 
{/if}
 </div>

<?php }?>


                                                    </div>
                    </div>
                    <hr>

{/volist}



 

                                        <div class="pager">{$page}</div>
                </div>

<script src="/assets/js/jquery-1.8.3.min.js"></script>
<script src="/assets/js/layer/layer.js"></script>
<script src="/assets/js/laydate/laydate.js"></script>

<script type="text/javascript">

    function editCarNo(id){
        layer.open({
                        type: 1,
                        title:"编辑信息",
                        skin: 'layui-layer-demo', //样式类名
                        shift: 2,
                        shadeClose: true, //开启遮罩关闭
                        area: ['300px','250px'],
                        content: '<br/><div class="col-md-12"><label class="control-label" for="account">车牌号：<b style="color: red">*</b></label><input type="text" class="form-control" id="car_no" name="car_no"  placeholder="请输入车牌号"></div><br/><div class="col-md-12"><label class="control-label" for="account">上牌时间：<b style="color: red">*</b></label><input type="text" readonly class="form-control" id="dj_time" name="dj_time"   placeholder="请输入上牌时间"></div>',
                        btn: ['确定','取消'],
                        success:function(index, layero){
                             laydate.render({
                              elem: '#dj_time' //指定元素
                            });
                         },
                        yes: function(index, layero){
                            if($('#car_no').val()==''||$('#car_no').val()==''){
                                layer.msg('请输入车牌号和上牌时间')
                            }else{
                                 editAjax(id,$('#car_no').val(),$('#dj_time').val());
                            }
                        },
                        cancel: function(index, layero){
                            //do something 
                        }

                    });
    }

    function editAjax(id,car_no,dj_time){
        $.ajax({
                    type: 'POST',
                    url: "{:url('user/editCarNo')}",
                    data: {id:id,car_no:car_no,dj_time:dj_time},
                    dataType: 'json',
                    beforeSend:function(result){
                       layer.load(1, {shade: [0.5,'#000'] });
                    },
                    success:function(result){  
                       layer.closeAll(); 
                       layer.msg(result.msg);  
                       location.reload();
                    },
                    error:function(data){
                        layer.closeAll();
                        layer.msg('网络异常,请稍后再试'); 
                    }

                }); 
    }
    function nullify(id){
        layer.confirm('确定作废该保单？', {
              btn: ['确定','取消'] //按钮
            }, function(){
              location.href="/index/order/nullify.html?ids="+id;
            }
            );
    }
</script>




            </div>
        </div>
    </div>
</div>